<template>
  <el-dialog
    class="collect-preview"
    title="文章预览"
    :visible.sync="dialogVisible"
    fullscreen
  >
    <div class="webheart collect-content">
      <p class="cite-title">{{ row.citeTitle }}</p>
      <h2 class="collect-title">{{ row.title }}</h2>
      <p class="sub-title">{{ row.subTitle }}</p>
      <p class="collect-info">
        <span v-if="row.author">作者：{{ row.author }}</span>
        <span v-if="row.source">来源：{{ row.source }}</span>
        <span v-if="row.pubDate">发布时间：{{ row.pubDate }}</span>
        <span v-if="row.clickCount">点击数：{{ row.clickCount }}</span>
      </p>
      <div class="outline" v-if="row.outline">
        <b>摘要：</b>
        {{ row.outline }}
      </div>
      <div class="" v-html="row.content"></div>
      <div class="collect-info-end">
        <p v-if="row.editor || row.auditor || row.photography">
          (
          <span v-if="row.editor">编辑：{{ row.editor }}</span>
          <span v-if="row.auditor">审核：{{ row.auditor }}</span>
          <span v-if="row.photography">摄影：{{ row.photography }}</span>
          )
        </p>
      </div>
      <div class="">
        <AttachmentList
          v-if="row.hasOwnProperty('fileList')"
          :fileList="row.fileList"
        />
      </div>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button type="info" @click="dialogVisible = false">关 闭</el-button>
    </span>
  </el-dialog>
</template>
<script>
export default {
  components: {
    AttachmentList: () => import('./AttachmentList.vue'),
  },
  data() {
    return {
      dialogVisible: false,
      row: {},
    }
  },
  mounted() {
    this.$bus.$on('collectLogPreview', (row) => {
      this.row = row
      this.dialogVisible = true
    })
  },
  beforeDestroy() {
    this.$bus.$off('collectLogPreview')
  },
  methods: {},
}
</script>
<style scoped lang="scss">
.collect-content {
  height: calc(100vh - 200px);
  overflow-y: auto;
  overflow-x: hidden;
  ::v-deep p {
    text-indent: 2em;
  }
  ::v-deep code {
    display: block;
    overflow-x: auto;
    padding: 0.5em;
    color: #333;
    background: #f8f8f8;
  }
  ::v-deep .cnblogs-markdown pre code,
  ::v-deep .cnblogs-post-body pre code {
    display: block;
    line-height: 1.5;
    margin: 0;
    white-space: pre-wrap;
  }
  ::v-deep pre {
    margin: 10px auto;
  }
  ::v-deep pre code {
    display: block;
    overflow-x: auto;
    padding: 1em;

    background: #f5f5f5;
    display: block;
    font-family: 'Courier New', sans-serif;
    font-size: 12px;
    border: 1px solid #ccc;
    padding: 1em;
    border-radius: 3px;
    overflow-x: auto;
  }
}
.collect-title {
  text-align: center;
  line-height: 2;
  color: #333;
  font-size: 22px;
}
.cite-title {
  color: #666;
  font-size: 16px;
  text-align: center;
}
.sub-title {
  color: #666;
  text-align: center;
  margin-top: -10px;
}
.collect-info {
  text-align: center;
  margin-bottom: 20px;
  span {
    margin: 0 10px;
  }
}
.outline {
  padding: 10px 15px;
  margin-bottom: 20px;
  border-radius: 10px;
  border: 3px dashed #eee;
}
.collect-info-end {
  text-align: right;
  margin-top: 10px;
  margin-bottom: 20px;
  span {
    margin: 0 10px;
  }
}
</style>
<style scoped>
.collect-preview >>> .el-dialog__footer {
  background: #fff;
}
.collect-preview >>> .el-dialog__body {
  border-top: 1px solid #ddd;
  background: #fff;
}
</style>